package com.cindata
class Community
{
    String address
    Province province
    City city
    District district
    Long communityId
    String communityName
    String propertyManagementCompany
    // 物业公司
    Integer buildYear
    //建筑年份
    BigDecimal plotratio
    //容积率
    BigDecimal coveringArea
    // 占地面积
    BigDecimal buildArea
    // 建筑面积
    Integer totalBuildingCount
    // 总楼栋数
    Integer totalHouseHoldCount
    // 总户数
    String pmfee
    //物业费
    String buildingstructureName
    // 建筑结构
    String residentialType
    // 建筑类型
    String developer
    // 开发商
    String buildingType
    // 建筑形式
    Double arcgisX
    Double arcgisY

    BigDecimal communityScore
    //小区评分
    BigDecimal communityCoverage
    // 小区覆盖率
    BigDecimal concentrationRatio
    // 小区押品集中度
    
    Date createdDate = new Date()
    Date modifiedDate = new Date()
    User user
    User createBy
    User modifyBy

    Account account

    static mapping = {
        autowire true
    }

    static constraints = 
    {
        address maxSize: 150, nullable: true, blank: true
        province nullable: true, blank: true
        city nullable: true, blank: true
        district nullable: true, blank: true
        communityId nullable: true, blank: true
        communityName maxSize: 50,  nullable: true, blank: true
        propertyManagementCompany maxSize: 50, nullable: true, blank: true
        buildYear nullable: true, blank: true
        plotratio nullable: true, blank: true
        coveringArea nullable: true, blank: true
        buildArea nullable: true, blank: true
        totalBuildingCount nullable: true, blank: true
        totalHouseHoldCount nullable: true, blank: true
        pmfee maxSize: 50, nullable: true, blank: true
        buildingstructureName maxSize: 50, nullable: true, blank: true
        residentialType maxSize: 50, nullable: true, blank: true
        developer maxSize: 50, nullable: true, blank: true
        buildingType maxSize: 50, nullable: true, blank: true
        arcgisX nullable: true, blank: true
        arcgisY nullable: true, blank: true
        communityScore nullable: true, blank: true
        communityCoverage nullable: true, blank: true
        concentrationRatio nullable: true, blank: true

        createdDate nullable: true, blank: true
        modifiedDate nullable: true, blank: true
        user nullable: true, blank: true
        createBy nullable: true, blank: true
        modifyBy nullable: true, blank: true
        
        account nullable: true, blank: true
    }

    def springSecurityService
    def beforeInsert()
    {
        def username = springSecurityService?.getPrincipal()?.username
        def user = User.findByUsername(username)
        createBy = user
    }

    def beforeUpdate()
    {
        modifiedDate = new Date()
        def username = springSecurityService?.getPrincipal()?.username
        modifyBy = User.findByUsername(username)
    }
}
